package com.yshy.moviechoseseatinginnerapi.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yshy.moviechoseseatinginnerapi.service.CinemasService;
import com.yshy.moviechoseseatingcommon.entity.bo.cinemas.GetByIdBo;
import com.yshy.moviechoseseatingcommon.entity.bo.cinemas.V1PagedQueryBo;
import com.yshy.moviechoseseatingcommon.entity.bo.cinemas.V2PagedQueryBo;
import com.yshy.moviechoseseatingcommon.entity.vo.cinemas.GetByIdVo;
import com.yshy.moviechoseseatingcommon.entity.vo.cinemas.ListAllBrandsVo;
import com.yshy.moviechoseseatingcommon.entity.vo.cinemas.V1PagedQueryVo;
import com.yshy.moviechoseseatingcommon.entity.vo.cinemas.V2PagedQueryVo;
import com.yshy.moviechoseseatingcommon.util.RequstUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author :
 * @desc :
 * @create: 上午11:07
 **/
@Service
public class CinemasServiceImpl implements CinemasService {
    @Autowired
    private RequstUtil requstUtil;
    @Override
    public String getById(GetByIdBo bo) {
        GetByIdVo getByIdVo = requstUtil.cinemasGetById(bo);
        if(getByIdVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(getByIdVo, SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String v1PagedQuery(V1PagedQueryBo bo) {
        if(bo.getCityId()==null&&bo.getCityCode()==null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        if(bo.getCityId()!=null&&bo.getCityCode()!=null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        V1PagedQueryVo v1PagedQueryVo = requstUtil.cinemasV1PagedQuery(bo);
        if(v1PagedQueryVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(v1PagedQueryVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String v2PagedQuery(V2PagedQueryBo bo) {
        if(bo.getCityId()==null&&bo.getCityCode()==null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        if(bo.getCityId()!=null&&bo.getCityCode()!=null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        V2PagedQueryVo v2PagedQueryVo =requstUtil.cinemasV2PagedQuery(bo);
        if(v2PagedQueryVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(v2PagedQueryVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String  listAllBrands() {
        ListAllBrandsVo listAllBrandsVo = requstUtil.cinemasListAllBrands();
        if(listAllBrandsVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listAllBrandsVo,SerializerFeature.WriteMapNullValue);
    }
}
